home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / Apple Remote Access Modem / Modem Workshop / 2.0 Example Script / 2.0 Example Script
Encoding:
Text File  |  1993-10-15  |  8.0 KB  |  412 lines  |  [mlts/slnk]

  1. !  Global Village Teleport Gold & Silver - Example Modem Script
  2. !
  3. !  'mlts' resource info for this modem:
  4. !    byte 1 == 01 -> modem HAS builtin reliability protocols
  5. !    byte 2 == 00 -> reserved by Apple
  6. !    byte 3 == 21 -> max hex chars in varstr 7 (33 dec)
  7. !    byte 4 == 21 -> max hex chars in varstr 8
  8. !    byte 5 == 21 -> max hex chars in varstr 9
  9. !    
  10. @ORIGINATE
  11. @ANSWER
  12. !
  13. ! set up the modem - label range is 1-10
  14. !
  15. ! Mac talks to the modem at 19,200 bps.  
  16. serreset 19200, 0, 8, 1
  17. !
  18. ! reset the serial port
  19. HSReset 0 0 0 0 0 0
  20. settries 0
  21. !
  22. @LABEL 1
  23. matchclr
  24. matchstr 1 3 "OK\13\10"
  25. ! &F  - recall factory settings
  26. ! &D3 - Reset Modem on On-to-Off DTR transitions
  27. ! &K3 - Enable CTS/RTS Hardware flow control
  28. ! \J0 - Disable auto port rate adjust
  29. ! W2  - Connect result code reports modem speed
  30. ! \Q2 - Unidirectional flow control
  31. ! S7=60 - To allow for an international call
  32. ! S0=0 - Don't answer calls
  33. ! E0   - Turn command echo off
  34. ! \N0 - Enter normal mode (no reliability protocols)
  35. write "AT&F&D3&K3\\J0W2\\Q2S7=60S0=0E0\\N0\13"
  36. matchread 30
  37. inctries
  38. iftries 2 71
  39. !
  40. ! Reset the Modem
  41. !
  42. DTRSet
  43. pause 5
  44. DTRClear
  45. pause 5
  46. DTRSet
  47. flush
  48. jump 1
  49. !
  50. @LABEL 3
  51. ! Modem responding & configured.
  52. ! determine if reliable link is requested.
  53. !
  54. ! if modem mnp10 link requested (var 4 == 2) then jump label 4
  55. ifstr 4 4 "2"
  56. !
  57. ! if modem v42 link requested (var 4 == 1) then jump label 5
  58. ifstr 4 5 "1"
  59. !
  60. ! if no modem v42 link requested (var 4 == 0) [same as ARA 1.0] then jump label 9
  61. ifstr 4 9 "0"
  62. !
  63. ! else invalid value in var 4; exit w/error
  64. jump 76
  65. !
  66. @LABEL 4
  67. ! use this label for mnp 10 type stuff, but
  68. ! THIS modem doesn't support mnp 10 links.
  69. jump 7
  70. !
  71. @LABEL 5
  72. ! yes, v42 link is requested.  OK for LAP-M -> MNP 4.
  73. matchclr
  74. matchstr 1 7 "OK\13\10"
  75. ! S95 = 72 (dec) gives PROTOCOL: and CONNECT result codes
  76. ! \N3 == v42 autoreliable mode
  77. ! %C0 == MNP 5 v42b disabled
  78. ! "H0 == LZW v42b disabled (substitute \34 for ")
  79. write "ATS95=72\\N3%C0\34H0\13"
  80. matchread 300
  81. jump 71
  82. !
  83. @LABEL 7
  84. ! if we DID want v42b in the modem, this is where it would go,
  85. ! but since the cpu does a better job at compressing compressable
  86. ! files, this setup stuff is commented out.  the matchstrings and
  87. ! associated labels have been left in.
  88. !matchclr
  89. !matchstr 1 9 "OK\13\10"
  90. ! S95 = 104 (dec) adds COMPRESSION: result codes
  91. ! %C1 == MNP 5 v42b enabled
  92. ! "H3 == LZW v42b enabled (substitute \34 for ")
  93. !write "ATS95=72%C1\34H3\13"
  94. !matchread 300
  95. !jump 71
  96. !
  97. @LABEL 9
  98. ! If speaker on flag is true, jump to label 13.  Else turn off the speaker.
  99. ifstr 2 13 "1"
  100. pause 5
  101. matchclr
  102. matchstr 1 13 "OK\13\10"
  103. write "ATM0\13"
  104. matchread 30
  105. jump 71
  106. !
  107. ! modem ready, so enable answering or originate a call - label range is 11-30
  108. !
  109. @LABEL 13
  110. pause 5
  111. ifANSWER 62
  112. !
  113. ! if normal dialing (parm 6 == 0) jump to 19
  114. ifstr 6 19 "0"
  115. !
  116. ! if blind dialing (parm 6 == 1) jump to 17
  117. ifstr 6 17 "1"
  118. !
  119. ! if manual dialing (parm 6 == 2) jump to 15 
  120. ifstr 6 15 "2"
  121. !
  122. ! else invalid value in var 6; exit w/error
  123. jump 76
  124. !
  125. @label 15
  126. note "Manual dialing initiated" 3
  127. ! X1 to ignore dialtone & busy for manual dialing, D to dial
  128. write "ATX1D \13"
  129. jump 32
  130. !
  131. @label 17
  132. note "Dialing without tone" 3
  133. matchclr
  134. matchstr 1 19 "OK\13\10"
  135. ! X1 to ignore dialtone & busy for blind dialing
  136. write "ATX1\13"
  137. matchread 30
  138. jump 71
  139. !
  140. @label 19
  141. ! this is where we break up long dialstrings
  142. !
  143. ! parm 1 is always the full dialstring from the conn doc
  144. note "Dialing ^1" 3
  145. ! parm 3 is always "p" for pulse & "t" for tone
  146. !
  147. ! if parm 8 == blank (complete dialstring in parm 7)
  148. !  then jump to label 27 & dial parm 7
  149. ifstr 8 27 " "
  150. !
  151. ! if parm 9 == blank (complete dialstring in parms 7 & 8)
  152. !  then jump to label 24 & dial parm 7 & 8
  153. ifstr 9 24 " "
  154. !
  155. !  else dial parm 7 & 8 & 9 (complete dialstring in parms 7, 8 & 9)
  156. matchclr
  157. matchstr 1 21 "OK\13\10"
  158. ! parm 7 holds first string fragment
  159. write "ATD^3^7;\13"
  160. matchread 400
  161. ! modem not responding; bailout.
  162. jump 71
  163. @label 21
  164. ! parm 8 holds second string fragment
  165. matchclr
  166. matchstr 1 22 "OK\13\10"
  167. write "ATD^3^8;\13"
  168. matchread 400
  169. ! modem not responding; bailout.
  170. jump 71
  171. @label 22
  172. ! parm 9 holds last string fragment
  173. write "ATD^3^9\13"
  174. jump 32
  175. !
  176. @label 24
  177. matchclr
  178. matchstr 1 25 "OK\13\10"
  179. ! parm 7 holds first string fragment
  180. write "ATD^3^7;\13"
  181. matchread 400
  182. ! modem not responding; bailout.
  183. jump 71
  184. @label 25
  185. ! parm 8 holds last string fragment
  186. write "ATD^3^8\13"
  187. jump 32
  188. !
  189. @label 27
  190. ! parm 7 holds entire string
  191. write "ATD^3^7\13"
  192. jump 32
  193. !
  194. !    connecting - label range is 31-60
  195. !
  196. @LABEL 32
  197. matchclr
  198. matchstr 1  34 "CONNECT 1200\13\10"
  199. matchstr 2  35 "CONNECT 2400\13\10"
  200. matchstr 3  36 "CONNECT 4800\13\10"
  201. matchstr 4  37 "CONNECT 7200\13\10"
  202. matchstr 5  38 "CONNECT 9600\13\10"
  203. matchstr 6  39 "CONNECT 12000\13\10"
  204. matchstr 7  40 "CONNECT 14400\13\10"
  205. ! other connect speeds go below here
  206. matchstr 8  68 "RING\13\10"
  207. matchstr 9  72 "NO DIALTONE\13\10"
  208. matchstr 10 73 "NO CARRIER\13\10"
  209. matchstr 11 73 "ERROR\13\10"
  210. matchstr 12 74 "BUSY\13\10"
  211. matchstr 13 75 "NO ANSWER\13\10"
  212. ! other error messages go below here
  213. matchstr 14 44 "PROTOCOL: NONE\13\10"
  214. matchstr 15 45 "PROTOCOL: MNP4\13\10"
  215. matchstr 16 46 "PROTOCOL: LAP-M\13\10"
  216. ! other PROTOCOL messages go below here
  217. matchstr 17 47 "COMPRESSION: NONE\13\10"
  218. matchstr 18 48 "COMPRESSION: MNP5\13\10"
  219. matchstr 19 49 "COMPRESSION: V.42BIS\13\10"
  220. matchread 700
  221. ifANSWER 32
  222. jump 71
  223. !
  224. !  THIS v32b modem has been setup to do cts handshaking,
  225. !  and we assume that a cts handshaking cable is being used,
  226. !  so we leave the serial port set to 19,200 bps.
  227. !  
  228. !  in a v32 or v22b modem, we assume the lower data rate won't require
  229. !  cts handshaking.  
  230. !
  231. @LABEL 34
  232. note "Communicating at 1200 bps." 2
  233. CommunicatingAt 1200
  234. jump 58
  235. !
  236. @LABEL 35
  237. note "Communicating at 2400 bps." 2
  238. CommunicatingAt 2400
  239. jump 58
  240. !
  241. @LABEL 36
  242. note "Communicating at 4800 bps." 2
  243. CommunicatingAt 4800
  244. jump 58
  245. !
  246. @LABEL 37
  247. note "Communicating at 7200 bps." 2
  248. CommunicatingAt 7200
  249. jump 58
  250. !
  251. @LABEL 38
  252. note "Communicating at 9600 bps." 2
  253. CommunicatingAt 9600
  254. jump 58
  255. !
  256. @LABEL 39
  257. note "Communicating at 12000 bps." 2
  258. CommunicatingAt 12000
  259. jump 58
  260. !
  261. @LABEL 40
  262. note "Communicating at 14400 bps." 2
  263. CommunicatingAt 14400
  264. jump 58
  265. !
  266. ! v42 link connections.
  267. ! userhook 2 tells ARA that a modem-to-modem error correcting protocol has been negotiated
  268. ! userhook 4 would tell ARA that a modem-to-modem mnp 10 protocol has been negotiated
  269. !
  270. @LABEL 44
  271. ! no error correction negotiated
  272. jump 32
  273. !
  274. @LABEL 45
  275. note "MNP4 Reliable Link Established." 3
  276. userhook 2
  277. jump 32
  278. !
  279. @LABEL 46
  280. note "LAP-M Reliable Link Established." 3
  281. userhook 2
  282. jump 32
  283. !
  284. ! v42b link connections.
  285. ! userhook 3 tells ARA that a modem-to-modem compression protocol has been negotiated
  286. !
  287. @LABEL 47
  288. ! no compression negotiated
  289. jump 32
  290. !
  291. @LABEL 48
  292. note "MNP5 Compression Established." 3
  293. userhook 3
  294. jump 32
  295. !
  296. @LABEL 49
  297. note "V.42BIS Compression Established." 3
  298. userhook 3
  299. jump 32
  300. !
  301. @LABEL 58
  302. ! turn on cts handshaking.
  303. HSReset 0 1 0 0 0 0
  304. !
  305. ifANSWER 59
  306. pause 30
  307. @LABEL 59
  308. exit 0
  309. !
  310. ! @ANSWER
  311. ! Set the modem to answer on 1st ring - label range is 61-70
  312. !
  313. @LABEL 62
  314. matchclr
  315. matchstr 1 32 "OK\13\10"
  316. write "ATS0=1\13"
  317. matchread 30
  318. jump 71
  319. !
  320. @LABEL 68
  321. ifORIGINATE 32
  322. ! claim the serial port
  323. userhook 1
  324. note "Answering phone..." 2
  325. jump 32
  326. !
  327. ! error messages - label range is 71-100
  328. !
  329. ! Modem Not Responding
  330. @LABEL 71
  331. exit -6019
  332. !
  333. ! No Dial Tone
  334. @LABEL 72
  335. exit -6020
  336. !
  337. ! No Carrier or Error
  338. @LABEL 73
  339. exit -6021
  340. !
  341. ! Busy
  342. @LABEL 74
  343. exit -6022
  344. !
  345. ! No Answer
  346. @LABEL 75
  347. exit -6023
  348. !
  349. ! varstring invalid value
  350. @LABEL 76
  351. exit -6027
  352. !
  353. ! Hang up the modem - label range is 101-120
  354. !
  355. @HANGUP
  356. @LABEL 102
  357. settries 0
  358. serreset 19200, 0, 8, 1
  359. HSReset 0 0 0 0 0 0
  360. @LABEL 105
  361. !
  362. ! Try to get control of the modem.
  363. !
  364. DTRSet
  365. pause 5
  366. DTRClear
  367. flush
  368. !
  369. @LABEL 108
  370. flush
  371. matchclr
  372. matchstr 1 111 "NO CARRIER\13\10"
  373. matchstr 2 111 "OK\13\10"
  374. matchstr 3 111 "ERROR\13\10"
  375. write "ATH\13"
  376. matchread 30
  377. inctries
  378. iftries 3 71
  379. DTRSet
  380. pause 5
  381. DTRClear
  382. pause 5
  383. DTRSet
  384. flush
  385. !
  386. @LABEL 109
  387. matchclr
  388. matchstr 1 115 "OK\13\10"
  389. write "+++"
  390. matchread 15
  391. jump 108
  392. !
  393. ! recall the factory settings.
  394. !
  395. @LABEL 111
  396. pause 15
  397. matchclr
  398. matchstr 1 114 "OK\13\10"
  399. write "AT&FS0=0\13"
  400. matchread 30
  401. jump 71
  402. !
  403. @LABEL 114
  404. exit 0
  405.  
  406. @LABEL 115
  407. pause 50
  408. jump 108
  409.  
  410. !
  411. ! labels 121-128 are reserved for future emergency hacks
  412. !